def isorted(ilist, reverse: false)
  tmp = Array.new(ilist)
  for i in 0...tmp.length
    for j in 0...tmp.length - i - 1
      if tmp[j] < tmp[j + 1] == reverse
        tmp[j], tmp[j + 1] = tmp[j + 1], tmp[j]
      end
    end
  end
  return tmp
end

list = [2, 1, 3, 4]
print isorted(list)
